<%--
  Created by IntelliJ IDEA.
  User: mac
  Date: 2017/12/27
  Time: 15:26
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
    <!-- bootstrap样式 -->
    <link rel="stylesheet" type="text/css" href="/bootstrap/css/bootstrap.min.css">

</head>
<body>
<div class="row">
    <div class="col-xs-6 col-md-3"></div>
    <div class="col-xs-6 col-md-6">
        <h2>展示页面</h2>
        <br><br>
        <form class="form-inline" role="form" action="getWeekList" method="post">
            <div class="form-group">
                <label class="sr-only" for="textname">请输入：</label>
                <input type="hidden" name="cpage">
                <input type="text" name="name" class="form-control" id="textname" placeholder="请输入...">
            </div>
            <button type="submit" class="btn btn-primary">提交</button>
        </form>
        <button type="button" onclick="toAddWeek()" class="btn btn-primary">新增</button>
        <table class="table table-striped table-bordered table-hover">
            <tr>
                <td>序号</td>
                <td>名字</td>
                <td>类型</td>
                <td>节日</td>
                <td>状态</td>
                <td>操作</td>
            </tr>
            <c:forEach items="${weekList}" var="b">
                <tr>
                    <td>${b.id}</td>
                    <td>${b.name}</td>
                    <td>${b.type}</td>
                    <td>${b.des}</td>
                    <td>${b.sor}</td>
                    <td>
                        <button type="button" class="btn btn-primary" onclick="toUpdateWeek(${b.id})">修改</button>
                        <button type="button" class="btn btn-primary" onclick="delWeek(${b.id})">删除</button>
                    </td>
                </tr>
            </c:forEach>
        </table>
        <center>
            <ul class="pagination pagination-lg">
                <li><a href="#" onclick="fenye(1)">首页</a></li>
                <li><a href="#" onclick="fenye(${page.prevPage})">&laquo;</a></li>
                <li><a href="#" onclick="fenye(1)">1</a></li>
                <li><a href="#" onclick="fenye(2)">2</a></li>
                <li><a href="#" onclick="fenye(3)">3</a></li>
                <li><a href="#" onclick="fenye(4)">4</a></li>
                <li><a href="#" onclick="fenye(5)">5</a></li>
                <li><a href="#" onclick="fenye(${page.nextPage})">&raquo;</a></li>
                <li><a href="#" onclick="fenye(${page.totalPage})">尾页</a></li>
            </ul>
        </center>
    </div>
    <div class="col-xs-6 col-md-3"></div>
</div>

</body>
<script type="text/javascript" src="/js/jquery-1.11.1.min.js"></script>
<!-- 引入bootstrap插件 -->
<script type="text/javascript" src="/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript">
    function fenye(cpage){
        $("[name='cpage']").val(cpage);
        $("form").submit();
    }
    function toAddWeek(){
        location.href="toAddWeek";
    }
    function delWeek(id){
        $.ajax({
            url:"delWeek",
            data:{id:id},
            dataType:"text",
            type:"post",
            success:function(data){
                if(confirm("是否删除当前选中数据？")){
                   alert(data);
                   location.reload();
                }
            }
        })
    }
    function toUpdateWeek(id){
        location.href="toUpdateWeek?id="+id;
    }
</script>
</html>
